import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { SecondCareerDesc } from "./getTaskSubWin/SecondCareerDesc";
import { SecondCareerDescData } from "./items/SecondCareerDescData";
import { GameConst } from "../../../component/gconst/GameConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ImagesConst } from "../../resource/ImagesConst";
import { ResFileConst } from "../../resource/ResFileConst";
import { MsgManager } from "../../manager/MsgManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { CareerCheckBoxItem } from "../career/careerChange/CareerCheckBoxItem";
import { ConstConfig } from "../../resource/ConstConfig";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GScrollPane } from "../../../../com/mui/controls/GScrollPane";
//class SecondCareerGetTaskWin
    
    export  class SecondCareerGetTaskWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(610, 500);
            this.titleHeight = 27;
            this.title = Language.getString(80229);
            this._btnGetTask.addEventListener(flash.events.MouseEvent.CLICK, this.clickGetTaskHandler);
            return;
        }

        public updateView(arg1: Array<any>, arg2: Boolean, arg3: Boolean): void
        {
            var loc3=null;
            var loc4=null;
            this._isLevel = arg2;
            var loc1=0;
            while (loc1 < this._careerDescs.length) 
            {
                loc3 = this._careerDescs[loc1] as SecondCareerDesc;
                loc4 = arg1[loc1] as SecondCareerDescData;
                loc3.updateView(loc4);
                ++loc1;
            }
            var loc2=Language.getStringByParam(80240, GameConst.SecondCareerLevel);
            if (arg2) 
            {
                this._check1.updateData(HTMLUtil.addColor(loc2, "#00ff00"), ImagesConst.careerCheckBox_downSkin, ResFileConst.careerChange);
            }
            else 
            {
                this._check1.updateData(HTMLUtil.addColor(loc2, "#ff0000"), ImagesConst.careerCheckBox_selectedSkin, ResFileConst.careerChange);
            }
            if (arg3) 
            {
                this._check2.updateData(HTMLUtil.addColor(Language.getString(80241), "#00ff00"), ImagesConst.careerCheckBox_downSkin, ResFileConst.careerChange);
            }
            else 
            {
                this._check2.updateData(HTMLUtil.addColor(Language.getString(80241), "#ff0000"), ImagesConst.careerCheckBox_selectedSkin, ResFileConst.careerChange);
            }
            return;
        }

        /* internal  */clickGetTaskHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._isLevel) 
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(80249, GameConst.SecondCareerLevel.toString()));
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.SecondCareerIGetTask));
            this.hide();
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc3=null;
            super.createChildren();
            this._careerDescs = [];
            var loc1=0;
            while (loc1 < 3) 
            {
                loc3 = new SecondCareerDesc();
                loc3.x = 18 + loc1 * 193;
                loc3.y = 38;
                this.addChild(loc3);
                this._careerDescs.push(loc3);
                ++loc1;
            }
            this._txtNeed1 = ObjCreate.createGTextField("", 45, 372, 200, 20, this);
            this._txtNeed1.htmlText = Language.getString(80239);
            this._check1 = new CareerCheckBoxItem();
            this._check1.x = 105;
            this._check1.y = 372;
            this.addChild(this._check1);
            this._check2 = new CareerCheckBoxItem();
            this._check2.x = 105;
            this._check2.y = 400;
            this.addChild(this._check2);
            this._btnGetTask = ObjCreate.createGLoadedButton(ResFileConst.SecondCarerrGetTaskBtn, 213, 375, 201, 48, this);
            ObjCreate.createBg(15, 424, 581, 66, this);
            this._txtDesc = ObjCreate.createGTextField("", 20, 427, 575, 100, this);
            var loc2=this._txtDesc.defaultTextFormat;
            loc2.leading = 3;
            this._txtDesc.defaultTextFormat = loc2;
            this._txtDesc.multiline = true;
            this._txtDesc.wordWrap = true;
            this._txtDesc.htmlText = Language.getStringByParam(80251, ConstConfig.instance.getValueByName("CareerSecondOpenCost"));
            return;
        }

        /* internal */ /* var */_careerDescs: Array<any>;

        /* internal */ /* var */_btnGetTask: GLoadedButton;

        /* internal */ /* var */_txtNeed1: GTextFiled;

        /* internal */ /* var */_txtNeed2: GTextFiled;

        /* internal */ /* var */_check1: CareerCheckBoxItem;

        /* internal */ /* var */_check2: CareerCheckBoxItem;

        /* internal */ /* var */_isLevel: Boolean;

        /* internal */ /* var */_txtDesc: GTextFiled;

        /* internal */ /* var */_descScrolPane: GScrollPane;
    }
